//
//  GYOAuthViewController.swift
//  Swift-sina
//
//  Created by gaoyanyun on 16/5/15.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class GYOAuthViewController: UIViewController {

    private lazy var webView = UIWebView()
    
    override func loadView() {
        view = webView
        
        //设置导航栏
        title = "登录新浪微博"
        navigationItem.leftBarButtonItem = UIBarButtonItem(
            
        title: "取消",
        style: .Plain,
        target: self,
        action: #selector(clickCloseButton))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(
        title:"自动填充",
        style: .Plain,
        target: self,
        action: #selector(clickAutoFillButton ))
        
        }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.whiteColor()
        
        //加载授权URL
        webView.loadRequest(NSURLRequest(URL: NetworkTools.sharedTools.oauthURL()))
    }
    
    //监听方法
    @objc private func clickCloseButton(){
        
         dismissViewControllerAnimated(true, completion: nil)
        
    }
    
    @objc private func clickAutoFillButton(){
        
        let js = ""
        
      webView.stringByEvaluatingJavaScriptFromString(js)
    }
}
